/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package deatax.display;

import deatax.Tile;
import javax.media.opengl.GL2;

/**
 *
 * @author Caroline
 */
public class WaterTileRenderer extends TileRenderer {

    private static Texture WATER_TEXTURE = new Texture("tiles/ocean.png");
    public static float water_offset = 0;

    public WaterTileRenderer() {
        addType("Water");
        addType("Ocean");
    }

    
    
    @Override
    public void update(long tick) {
        super.update(tick);
        water_offset = (water_offset + 0.0005f) % 1f;
    }
    
    
    
    
    @Override
    public void draw(GL2 gl, Tile t, float px, float py, float rotation) {
        super.draw(gl, t, px, py, rotation);
        WATER_TEXTURE.bind(gl);
        gl.glEnable(GL2.GL_TEXTURE_2D);
        gl.glTexParameterf(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_WRAP_S,GL2.GL_REPEAT );
        gl.glTexParameterf(GL2.GL_TEXTURE_2D,GL2.GL_TEXTURE_WRAP_T,GL2.GL_REPEAT );

        gl.glBegin(GL2.GL_TRIANGLE_FAN);
        for (int i = 0; i < 12; i += 2) {
            gl.glTexCoord2f(hex_texture[i] + water_offset, hex_texture[i+1] );
            gl.glVertex3f(hex_inner[i] + px, hex_inner[i + 1] + py, TILE_BEVEL);
        }
        gl.glEnd();
        gl.glDisable(GL2.GL_TEXTURE_2D);

    }
    
}
